# Huawei Technologies Co.,Ltd.

set(RESTARGS_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/restargs.txt)
set(RESTARGS_BIN ${CMAKE_CURRENT_BINARY_DIR}/restargs.abc)
set(RESTARGS_JS ${CMAKE_CURRENT_SOURCE_DIR}/restargs.js)
set(RESTARGS_VERIFY ${CMAKE_CURRENT_SOURCE_DIR}/verify.sh)

set(RUNTIME_ARGUMENTS --boot-panda-files=${CMAKE_BINARY_DIR}/pandastdlib/arkstdlib.abc --compiler-enable-jit=false --load-runtimes \"ecmascript\" ${RESTARGS_BIN} _GLOBAL::func_main_0)

add_custom_command(
    OUTPUT ${RESTARGS_OUTPUT}
    COMMENT "running javascript restargs testcase"
    COMMAND ${PANDA_RUN_PREFIX} $<TARGET_FILE:es2panda> ${RESTARGS_JS}  --output ${RESTARGS_BIN} 
    COMMAND rm -f ${RESTARGS_OUTPUT}
    COMMAND ${PANDA_RUN_PREFIX} $<TARGET_FILE:ark> ${RUNTIME_ARGUMENTS} 2>&1 > ${RESTARGS_OUTPUT}
    COMMAND bash ${RESTARGS_VERIFY} ${RESTARGS_OUTPUT}
)
add_custom_target(restargs
    DEPENDS ${RESTARGS_OUTPUT} ${RESTARGS_VERIFY}
)
add_dependencies(restargs es2panda ark)
add_dependencies(ecmascript_common_tests restargs)
